package com.example.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.Comment;
import com.example.demo.mapper.CommentMapper;
import com.example.demo.service.impl.CommentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-05-18
 */
@Controller
public class CommentController {

    @Autowired
    private CommentServiceImpl commentserviceimpl;

    @Autowired
    private CommentMapper commentMapper;

    @GetMapping(value = "/ceshi")
    @ResponseBody
    public String ceshi()
    {

        QueryWrapper<Comment> commentQueryWrapper = new QueryWrapper<>();

        commentQueryWrapper.eq("superior_id",-1);

        List<Comment> comments = commentMapper.selectList(commentQueryWrapper);

        commentserviceimpl.combineChildren(comments);


        System.out.println("===============================================");

        for (Comment comment : comments) {

            System.out.println(comment);

        }
        System.out.println("===============================================");

        return "hhh";
    }

}

